package com.cyzy.controller;

import com.cyzy.dto.ResponseDto;
import com.cyzy.pojo.CarModel;
import com.cyzy.service.HitCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author cuncun
 * @create 2025-05-28 上午9:03
 * 打车controller
 */

@RestController
@RequestMapping("/hitCar")
public class HitCarController {

    @Autowired
    private HitCarService hitCarService;

//    获取车类型（拼车、专车）
    @GetMapping("/getType")
    public ResponseDto getType(){

        List<CarModel> modelName = hitCarService.getModelName();

        return ResponseDto.ok(modelName);
    }

    //查询车类型信息（并计算对应的价格）  kilometer：公里数
    @GetMapping("/getCarTypes")
    public ResponseDto getCarTypes(@RequestParam("kilometer") double kilometer){

        List<CarModel> carTypes = hitCarService.getCarTypes(kilometer);

        System.out.println(carTypes);
        return ResponseDto.ok(carTypes);
    }
}
